package com.cms.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cms.common.StringUtils;
import com.cms.model.TrAdminUser;
import com.cms.service.ReportService;


@Controller
public class MainController extends BaseController{

	 @Autowired
	 private ReportService reportService;
	
	 /***
	  * 
	  * @param req
	  * @param resp
	  * @param map
	  * @return
	  * @throws Exception
	  */
	 @RequestMapping("/main/homepage.do")
	 public String toHomePage(HttpServletRequest req,HttpServletResponse resp,ModelMap map)throws Exception
	 {
		 TrAdminUser user = super.getLoginUser(req); 
		 Map<String,Object>param = new HashMap<String, Object>();
		 param.put("id", user.getId());
		 Map<String,Object>result = this.reportService.querySingleResult("queryUserDefaultPage", param);
		 String url = StringUtils.obj2String(result.get("defaultPage"));
		 return url;
	 }
}
